﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Model.Sec
{
    public class UnitCollection : IListSource
    {
        private Unit[] _units;
        private int _Count;

        bool IListSource.ContainsListCollection
        {
            get { return false; }
        }
        System.Collections.IList IListSource.GetList()
        {
            BindingList<Unit> ble = new BindingList<Unit>();


            foreach (Unit unit in _units)
            {
                ble.Add(unit);
            }


            return ble;
        }



        /// <summary>
        /// 单元集合的构造函数
        /// </summary>
        /// <param name="Length">长度</param>
        public UnitCollection(int Count)
        {
            this._Count = Count;
            _units = new Unit[this._Count];
        }
        /// <summary>
        /// 集合的长度
        /// </summary>
        public int Count
        {
            get { return _units.Length; }
        }
        /// <summary>
        /// 读取或设置索引为index的Unit对象
        /// </summary>
        /// <param name="index">索引值</param>
        /// <returns>Unit对象</returns>
        public Unit this[int index]
        {
            get
            {
                return _units[index];
            }
            set
            {
                _units[index] = value;
            }
        }
        public Unit[] units
        {
            get { return this._units; }
        }
    }
}
